;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
Scriptname Fragments:Perks:PRKF_ArtyBinos_PerkTargeter_01006B08 Extends Perk Hidden Const

; Properties
Quest Property BinocularControllerQuest Auto Const

Function Fragment_Entry_00(ObjectReference akTargetRef, Actor akActor)
	BinocularControllerQuest.CallArtillery(akTargetRef, akActor)
EndFunction



------------------------------

Scriptname ArtyBinoculars:ArtyBinosControllerQuest extends Quest Const

; Properties
Keyword Property MinArtilleryStart Auto Const
MinArtilleryScript Property ArtilleryQuest Auto Const

Function CallArtillery(ObjectReference akTargetRef, Actor akActor)
	
	Bool bRadioOn = Game.IsPlayerRadioOn()					; Get whether the player radio is on as a variable.
	Float fCurrentFrequency = Game.GetPlayerRadioFrequency()		; Get the current Radio frequency as a variable.
	Int iQuestStage = ArtilleryQuest.GetStage()				; Integer for the Artillery quest stage as a variable. 

	Location TargetLocation = akTargetRef.GetCurrentLocation()				
	MinArtilleryStart.SendStoryEvent(akLoc = TargetLocation, akRef1 = akTargetRef)
	
	If (ArtilleryQuest.IsRunning())
		While (iQuestStage != 500)
			If (Game.IsPlayerListening(105.0))					; Check to see if the player's is already listening to radio freedom.
				; empty statement
		
			ElseIf (bRadioOn == False)						; Then check to see if the radio is on, if it is off then...
				Game.TurnPlayerRadioOn()					; Turn it on and set the frequency to radio freedom.
				Game.SetPlayerRadioFrequency(105.00)
		
			ElseIf (bRadioOn == True && fCurrentFrequency != 105.00)		; Check to see if the Radio is on and the player is listening to something else
				Game.SetPlayerRadioFrequency(105.00)				; If it wasn't then tune in.
			EndIf
		EndWhile

											; On the end stage for the artillery quest
		If (bRadioOn == False)							; If the player radio was originally off then turn it back off.
			Game.TurnPlayerRadioOn(False)
		ElseIf (bRadioOn == True)						; Else set to back to the frequency that it started on.
			Game.SetPlayerRadioFrequency(fCurrentFrequency)
		EndIf
	EndIf
		
EndFunction